home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2 Examples.sit
/
Raven 1.2 Examples
/
Quill
/
Source
/
BasePaneEditor.inc
< prev
next >
Wrap
Text File
|
1997-07-27
|
6KB
|
223 lines
/*
* File: BasePaneEditor.inc
* Summary: Abstract base class for view's that edit pane objects.
* Written by: Jesse Jones
*
* Copyright ゥ 1996 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <-> 10/15/96 JDJ Created
*/
#include <ZAutoPtr.h>
#include <ZMultipleUndoableCommand.h>
#include <ZWindow.h>
// ===================================================================================
// class CBaseEditPaneCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CBaseEditPaneCommand::~CBaseEditPaneCommand
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO>
CBaseEditPaneCommand<PANE, PANEINFO>::~CBaseEditPaneCommand()
{
}
//---------------------------------------------------------------
//
// CBaseEditPaneCommand::CBaseEditPaneCommand
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO>
CBaseEditPaneCommand<PANE, PANEINFO>::CBaseEditPaneCommand(PANE* pane, const PANEINFO& oldInfo, const PANEINFO& newInfo) : mPane(pane)
{
ASSERT(pane != nil);
mOldInfo = oldInfo;
mNewInfo = newInfo;
TWindow* window = dynamic_cast<TWindow*>(mPane->GetTopView());
if (window != nil)
mContext = window->GetUndoContext();
else
mContext = nil;
mDelete = mContext == nil;
}
//---------------------------------------------------------------
//
// CBaseEditPaneCommand::GetText
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO>
string CBaseEditPaneCommand<PANE, PANEINFO>::GetText() const
{
return ""; // should be inside a transaction
}
//---------------------------------------------------------------
//
// CBaseEditPaneCommand::IsValid
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO>
bool CBaseEditPaneCommand<PANE, PANEINFO>::IsValid() const
{
return mPane.TargetExists();
}
//---------------------------------------------------------------
//
// CBaseEditPaneCommand::OnDo
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO>
void CBaseEditPaneCommand<PANE, PANEINFO>::OnDo()
{
this->UpdatePane(mNewInfo);
}
//---------------------------------------------------------------
//
// CBaseEditPaneCommand::OnUndo
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO>
void CBaseEditPaneCommand<PANE, PANEINFO>::OnUndo()
{
this->UpdatePane(mOldInfo);
}
//---------------------------------------------------------------
//
// CBaseEditPaneCommand::OnRedo
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO>
void CBaseEditPaneCommand<PANE, PANEINFO>::OnRedo()
{
this->UpdatePane(mNewInfo);
}
#pragma mark -
// ===================================================================================
// CBasePaneEditor
// ===================================================================================
//---------------------------------------------------------------
//
// CBasePaneEditor::~CBasePaneEditor
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO, class EDITCOMMAND>
CBasePaneEditor<PANE, PANEINFO, EDITCOMMAND>::~CBasePaneEditor()
{
}
//---------------------------------------------------------------
//
// CBasePaneEditor::CBasePaneEditor
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO, class EDITCOMMAND>
CBasePaneEditor<PANE, PANEINFO, EDITCOMMAND>::CBasePaneEditor(TView* superView) : CRootPaneEditor(superView)
{
mPane = nil;
}
//---------------------------------------------------------------
//
// CBasePaneEditor::SetPane
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO, class EDITCOMMAND>
void CBasePaneEditor<PANE, PANEINFO, EDITCOMMAND>::SetPane(TPane* pane)
{
ASSERT(pane != nil);
ASSERT(mPane == nil);
mPane = dynamic_cast<PANE*>(pane);
ASSERT(mPane != nil);
mOldInfo = mPane->GetInfo();
this->SetEditorInfo(mOldInfo);
}
//---------------------------------------------------------------
//
// CBasePaneEditor::Apply
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO, class EDITCOMMAND>
void CBasePaneEditor<PANE, PANEINFO, EDITCOMMAND>::Apply()
{
PANEINFO info = this->GetEditorInfo();
this->SetPaneInfo(info);
}
//---------------------------------------------------------------
//
// CBasePaneEditor::Commit
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO, class EDITCOMMAND>
void CBasePaneEditor<PANE, PANEINFO, EDITCOMMAND>::Commit(TMultipleUndoableCommand* command)
{
PANEINFO newInfo = this->GetEditorInfo();
command->AddCommand(new EDITCOMMAND(mPane, mOldInfo, newInfo));
}
//---------------------------------------------------------------
//
// CBasePaneEditor::Revert
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO, class EDITCOMMAND>
void CBasePaneEditor<PANE, PANEINFO, EDITCOMMAND>::Revert()
{
this->SetEditorInfo(mOldInfo);
this->SetPaneInfo(mOldInfo);
}
//---------------------------------------------------------------
//
// CBasePaneEditor::SetPaneInfo
//
//---------------------------------------------------------------
template <class PANE, class PANEINFO, class EDITCOMMAND>
void CBasePaneEditor<PANE, PANEINFO, EDITCOMMAND>::SetPaneInfo(const PANEINFO& info)
{
TAutoPtr<EDITCOMMAND> command(new EDITCOMMAND(mPane, mOldInfo, info));
command->UpdatePane(info);
}